<template>
    <div class="table">
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item><i class="el-icon-tickets"></i> 用户管理</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <el-table :data="data" border style="width: 100%" ref="multipleTable" @selection-change="handleSelectionChange">
              
                <el-table-column prop="logo" label="用户头像" >
                <template slot-scope="scope">
                   <img width="64px" height="64px" :src="scope.row.logo"/>
                    </template>
                </el-table-column>
                <el-table-column prop="tel" label="用户账号" >
                </el-table-column>
                <el-table-column prop="name" label="用户名称" >
                    </el-table-column>
                <el-table-column prop="sex" label="性别" ></el-table-column>
                <el-table-column prop="bir" label="生日" ></el-table-column>
                <el-table-column prop="job" label="职业" ></el-table-column>
                <el-table-column prop="autograph" label="签名" >
                </el-table-column>
            </el-table>
            <div class="pagination">
                <el-pagination @current-change="handleCurrentChange" layout="prev, pager, next"  :total="totalpage">
                </el-pagination>
            </div>
        </div>
    
        </div>
</template>

<script>
    export default {
        data() {
            return {
                url: '/api/getuser',
                tableData: [],
                cur_page: 1,
                multipleSelection: [],
                del_list: [],
                totalpage:0,
                delVisible: false,
                sender_letter:{

                },
                sendVisible:false,
                idx: -1
            }
        },
        created() {
            this.getData();
        },
        computed: {
            data() {
                return this.tableData
            }
        },
        methods: {
            // 分页导航
            handleCurrentChange(val) {
                this.cur_page = val;
                this.getData();
            },
            // 获取 easy-mock 的模拟数据
            getData() {
                // 开发环境使用 easy-mock 数据，正式环境使用 json 文件
            
                this.$axios.post(this.url, {
                    page: this.cur_page
                }).then((res) => {
                    console.log(res.data);
                    this.tableData = res.data.data;
                    this.cur_page=res.data.current_page
                    this.totalpage=res.data.total
                    console.log(this.totalpage);
                })
              
                
            },
            handleDelete(index, row) {
                this.idx = index;
                this.delVisible = true;
            },
            formatter(row, column) {
                return row.address;
            },
            delAll() {
                this.delVisible = false
                this.$axios.post("/api/badlist/del", {
                    page: this.cur_page,
                    id: this.multipleSelection
                }).then((res) => {
                    console.log(res.data);
                    this.tableData = res.data.data;
                    this.cur_page=res.data.current_page,
                    this.totalpage=res.data.total
                    this.$message.success('删除成功');
                })
                this.multipleSelection = [];
            },
            handleSelectionChange(val) {
                
                this.multipleSelection = [];
                val.forEach(element => {
                    this.multipleSelection.push(element.id)
                });
            },
          
            // 确定删除
            deleteRow(){
                this.delVisible = false
                this.$axios.post("/api/dish/del", {
                    page: this.cur_page,
                    id: this.tableData[this.idx].DishId
                }).then((res) => {
                    console.log(res.data);
                    this.tableData = res.data.data;
                    this.cur_page=res.data.current_page,
                    this.totalpage=res.data.total
                    this.$message.success('删除成功');
                })
               
            }
        }
    }

</script>

<style scoped>
    .handle-box {
        margin-bottom: 20px;
    }

    .handle-select {
        width: 120px;
    }

    .handle-input {
        width: 300px;
        display: inline-block;
    }
    .del-dialog-cnt{
        font-size: 16px;
        text-align: center
    }
</style>
